import 'dart:io';

import 'package:dio/dio.dart';
import 'cn_net_exception.dart';

//自定义拦截器
class CnHttpInterceptor extends Interceptor
{
  //请求拦截
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler)
  {
    // TODO: implement onRequest
    super.onRequest(options, handler);
  }

  //响应拦截
  @override
  Future onResponse(Response response, ResponseInterceptorHandler handler) async
  {
    // TODO: implement onResponse
    super.onResponse(response, handler);
  }

  //异常拦截
  @override
  Future onError(DioError err, ErrorInterceptorHandler handler) async
  {
    CnHttpException httpException = CnHttpException.create(err);
    err.error = httpException;

    // TODO: implement onError
    super.onError(err, handler);
  }



}